#include <iostream>
#include <cmath>
#define N 100

using namespace std;

void read_matrix(int matrix[N][N], int row, int column){
int i, j;
for (i=0;i<row;i++)
    for(j=0;j<column;j++){
        cout<<"["<<i<<"]["<<j<<"]= ";
        cin>>matrix[i][j];}
}

void print_matrix(int matrix[N][N], int row, int column){
int i,j;
for (i=0;i<row;i++){
    for(j=0; j<column; j++)
			cout<<matrix[i][j]<<" ";
		cout<<endl;}
}

int main(){
int row;
int column;
int matrix[N][N];
int i,j;
int sum=0;
int elements=0;

cout<<"Type the number of rows: " ;
cin>>row;

cout<<"Type the number of columns: " ;
cin>>column;

read_matrix(matrix, row, column);

for(i=0;i<row;++i)
    for (j=0;j<column;++j){
        if(i==j && matrix[i][j]>0){
            sum += matrix[i][j];
            ++elements;}
        if(i==column-j-1 && matrix[i][j]>0){
            sum += matrix[i][j];
            ++elements;}
}

print_matrix(matrix, row,column);

cout<<"The average of the positive values from the primary and secondary diagonals is: " << (float)sum/elements<<endl;

return 0;
}
